<script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=YahooDemo">
</script> 
<img src="../xpresso/html/images/Spacer.gif" onLoad="initialize()">
<div class="YahooMap">
	<div id="mapContainer"></div> 
	<script type="text/javascript"> 
		var pointLat;
		var pointLon;
		
		var initialPoint = new YGeoPoint(10,-40);
		var map = new YMap(document.getElementById('mapContainer')); 
		map.addPanControl(); 
		map.addZoomLong(); 
		map.drawZoomAndCenter(initialPoint, 16); 
		map.setMapType(YAHOO_MAP_HYB);
	
		var myFunction = function(_e,_c) {
			map.removeMarker("point");
			map.addMarker(_c, "point");
			map.getMarkerObject("point").addAutoExpand("Aqui ocurrio la noticia");
			pointLat = _c.Lat;
			pointLon = _c.Lon;
			
		};
	
		YEvent.Capture(map,EventsList.MouseDoubleClick,myFunction);
		
		
		function searchInMap(searchString){
			map.drawZoomAndCenter(searchString, 7)
			pointLat = map.getCenterLatLon().Lat;
			pointLon = map.getCenterLatLon().Lon;
			// map.addMarker(map.getCenterLatLon(), "point"); --> This is not returning the center of the map.
			// 		This should be called when the map is done drawing.
		}
		
		function resetMap(){
			map.drawZoomAndCenter(initialPoint, 16); 
			map.removeMarker("point");
			pointLat = 0;
			pointLon = 0;
		}
		
		function finish(){
			if (pointLat && pointLon && pointLat != 0 && pointLon != 0){
				var thePoint = new Object();
				thePoint.lat = pointLat;
				thePoint.lon = pointLon;
				window.opener.coordinatesDone(thePoint);
				window.close();
			} else{
				alert(window.opener.mapLanguage.pointmsg);
			}
			
		}
		
		function initialize(){
			document.getElementById("searchButton").value = window.opener.mapLanguage.search;
			document.getElementById("resetButton").value = window.opener.mapLanguage.reset;
			document.getElementById("finishButton").value = window.opener.mapLanguage.finish;
			
			var initialSearchString = "";
			if (window.opener.document.getElementById("City").value && window.opener.document.getElementById("City").value != ""){
				initialSearchString = window.opener.document.getElementById("City").value + " ,";
			}
			if (window.opener.document.getElementById("State").value && window.opener.document.getElementById("State").value != ""){
				initialSearchString = initialSearchString + window.opener.document.getElementById("State").value + " ,";
			}
			if (window.opener.document.getElementById("Country").value && window.opener.document.getElementById("Country").value != ""){
				initialSearchString = initialSearchString + window.opener.document.getElementById("Country").value;
			}
			if (initialSearchString != ""){
				document.getElementById("searchString").value = initialSearchString;
			}
			
		}		
	</script> 
</div>
<div class="YahooMapButtons">
	<input type="text" id="searchString" size="35">
	<input type="submit" name="Submit2" value="Search" id="searchButton" onClick="searchInMap(document.getElementById('searchString').value)">
	<input type="submit" name="Submit3" value="Reset" id="resetButton" onClick="resetMap()">
	&nbsp;
	<input type="submit" name="Submit" value="Finish !" id="finishButton" onClick="finish()">
</div>
